#include <stdio.h>
#include <stdlib.h>

int main()
{
	void printf_photo();
	void Narcissistic_number();
	int Sn_sum(int , int );
	int a = 5;
	int S;
	printf_photo();
	Narcissistic_number();
	S = Sn_sum(a, 5);
	printf("%d\n", S);
	system("pause");
	return 0;
}

void printf_star(int width)
{
	int i;
	for (i = 0; i < width; i++)
	{
		printf("* ");
	}
	printf("\n\n");
}

void printf_space(int width)
{
	int i;
	for (i = 0; i < width; i++)
	{
		printf("  ");
	}
}

void printf_photo()
{
	int i;
	int j = 1;
	for (i = 1; i < 14; i += 1)
	{
		printf_space(7 - (j + 1) / 2);
		printf_star(j);
		if (i < 7)
		{
			j += 2;
		}
		else
		{
			j -= 2;
		}
	}
}

int power_x(int x, int p)
{
	int m = x;
	while (p > 1)
	{
		m = m * x;
		p--;
	}
	return(m);
}

void Narcissistic_number()
{
	int i, j;
	for (i = 152; i < 999999; i++)
	{
		int count = 0, tmp, sum = 0;
		tmp = i;
		while (tmp != 0)
		{
			tmp =  tmp / 10;
			count++;
		}
		tmp = i; 
		j = count;
		for (j = 0; j < count; j++)
		{
			sum = sum + power_x(tmp - 10 * (tmp / 10), count);
			tmp = tmp / 10;
		}
		if (sum == i)
			printf("%d ", sum);
	}
}

int Sn_sum(int a,int n)
{
	int i, sum = 0, figure = 1;
	for (i = 0; i < n; i++)
	{
		sum = (n - i) * a * figure + sum;
		figure = figure * 10;
	}
	return 0;
}